/**
 * 
 */
$(function() {
	//时间下拉框
	$.ajax({
        url:easyExt.url+'/ssph/getDateList',
        dataType:'json',  
        success:function(data){
        	$.each(data.date, function(i, date){
        		$("#date").append("<option value='"+date+"'>"+date+"</option>");
        	});
        	$("#date").combobox({});
        }
     });
	$("#search").click(function() {
		var date = $("#date").combobox('getValue');
		$.ajax({
	        url:easyExt.url+'/ssph/get?date='+date,
	        dataType:'json',  
	        success:function(data){
	        	if (data.success == false) {
	        		$('#dg').find("tbody").empty();
					$.messager.alert("提示",
							data.msg, "error");
				} else {
					$('#dg').find("tbody").empty();
					debitSum = 0,creditSum = 0;
					for(o in data){
						$('#dg').find("tbody").append("<tr><td>"+ data[o].captionId
								+ "</td><td>"+data[o].name+"</td><td>"+data[o].debitAmount+"</td><td>"+ data[o].creditAmount+ "</td></tr>");
						debitSum=easyExt.accAdd(Number(debitSum),Number(data[o].debitAmount));
						creditSum=easyExt.accAdd(Number(creditSum),Number(data[o].creditAmount));
					}
					$('#dg').find("tbody").append("<tr><td></td><td>合计</td><td>"+debitSum+"</td><td>"+creditSum+"</td></tr>");
				}
	        },error : function() {
				$.messager.alert('提示', "错误",
				"error");
	         }
	     });
	});
	
});